<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>关键技术列表</title>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <link rel="stylesheet" href="../css/page_css/util.css">
</head>

<body>
	<div class="mui-content">
		<ul class="mui-table-view01">
			 <li class="search-cell">
			 	<div class="mui-input-row mui-search">
					<input type="search" id="searchText" onclick="openSearchWin()" readonly="readonly" class="mui-input-clear" placeholder="请输入关键字" ><span class="mui-icon mui-icon-clear mui-hidden"></span><span class="mui-placeholder"><span></span></span>
				</div>
				<div class="mui-btn mui-btn-primary" tapmode onclick="Search()">
					搜索
				</div>
			 </li>
		</ul>
		<div id="ordrListsContent">
			<script type="text/template" id="itemslist">
        {{each datas as item i}}
  			<div class="mui-card">
  				<ul class="mui-table-view mui-table-view-chevron">
  					<li class="mui-table-view-cell mui-collapse">
  						{{if item.isTimeOut == '1'}}
  						<a class="mui-navigate-right zdmb" href="#"><img src="../image/warning.png" style="width:0.8rem;display:inline-block;margin-right:0.2rem;"/>区域：{{item.locationSimple}}
  						{{else}}
  						<a class="zdmb" href="#">标题：{{item.description}}
  						{{/if}}
  							<span class="mui-badge mui-badge-inverted" style='margin-top: 10px'>负责人:{{item.leadName}}</span>
  							<div style="font-size: .6rem;">区域：{{item.locationSimple}}</div>
  						</a>
              <a class="zdmb" href="#" style="white-space: initial;font-size: .6rem;padding-top: 2px!important;">时间：{{item.statusdate}}</a>
  					</li>
  				</ul>
  				<div class="mui-card-footer">
  				{{if item.worktype == 'T04' }}
            {{if item.isHasAttach == 1}}
            <a class="mui-card-link" tapmode onclick="openOrderDetailWin('{{item.workorderid}}', '{{item.wonum}}',api.pageParam.orderType)">点击查看附件</a>
            {{else}}
            <span>无附件</span>
            {{/if}}
          {{else if item.home == 'home' && item.worktype == 'T03'}}
  					<a class="mui-card-link" tapmode onclick="openFile(api.pageParam.cRegion,{{item.workorderid}})">查看TIS</a>
  				{{else}}
            {{if item.isHasAttach == 1}}
              <a class="mui-card-link" tapmode onclick="openOrderDetailWin('{{item.workorderid}}', '{{item.wonum}}',api.pageParam.orderType)">点击查看附件</a>
            {{else}}
            <span>无附件</span>
            {{/if}}
    		  {{/if}}
  				</div>
  			</div>
  			{{/each}}
      </script>
		</div>

	</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/template.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	var searchText, UISearchBar = null;
  var curPage = 1
	apiready = function () {
		UISearchBar = api.require('UISearchBar');
		if (api.pageParam.searchText){
			$api.val($api.byId('searchText'), api.pageParam.searchText)
		}
		onLoadData(curPage,false);
		scrollToBottomHandler(function() {
			if (!loadEnd) { // 没有结束时继续加载
				curPage++;
				onLoadData(curPage,true);
			} else { // 告诉到底了
				EndToast('到底了');
			}
		})
		Refresh(function() {
      loadEnd = false;
			curPage = 1;
			onLoadData(curPage,false);
		});
	}
	function openOrderDetailWin(workorderid, wonum, orderType){
    openWin('work_order_manage_checkAccessories','查看附件',{
        background: '#6098de',
        color: '#fff'
    },{
      workorderid:workorderid,
      wonum: wonum,
      orderType: orderType
    })
	}
	function onLoadData (page,load) {
		searchText = $api.val($api.byId('searchText'));
    let params = {
      description: searchText,
      worktype: api.pageParam.orderType,
      pageNo: page,
      pageSize: 10
    }
		ajaxrd("queryTechnicalDocOrderList", params, function(ret, err) {
      ret.list.forEach(function(item){
        item.statusdate = formatDate(item.statusdate, 'YY-MM-DD hh:mm:ss')
      })
			AddData('itemslist', 'ordrListsContent', ret.list, load);
			if (ret.list.length < 10) {
				loadEnd = true
			}
		})
	}
	function openSearchWin(){
		UISearchBar.open({
		    placeholder: '请输入搜索关键字',
		    historyCount: 10,
		    showRecordBtn: false,
		    dataBase: 'workOrder',
		    texts: {
		        cancelText: '取消',
		        clearText: '清除搜索记录'
		    },
		    styles: {
		        navBar: {
		            bgColor: '#3398dc',
		            borderColor: '#ccc'
		        },
		        searchBox: {
		            bgImg: '',
		            color: '#000',
		            height: 35,
		            size: 13
		        },
		        cancel: {
		            bg: 'rgba(0,0,0,0)',
		            color: '#fff',
		            size: 15
		        },
		        list: {
		            color: '#696969',
		            bgColor: '#FFFFFF',
		            borderColor: '#eee',
		            size: 15
		        },
		        clear: {
		            color: '#000000',
		            borderColor: '#ccc',
		            size: 15
		        }
		    }
		}, function(ret, err) {
		    if (ret && (ret.eventType == 'search' || ret.eventType == 'history')) {
		        $api.val($api.byId('searchText'),ret.text);
		        Search();
		    } else {
		        //alert(JSON.stringify(err));
		    }
		});
	}
</script>

</html>
